import { type Dayjs } from 'dayjs';

export interface SearchInfo {
	username?: string;
	password?: string;
	phone?: string;
	code?: string;
	status?: string;
	wechatOpenid?: string;
	wechatUnionid?: string;
	avatar?: number;
	self?: number;
	wechatBindTime?: Dayjs | string;
	introUserId?: number;
	codeNum?: number;
	source?: number;
}

export interface pageInfo {
	current?: number;
	pageSize?: number;
	total?: number;
	showTotal: Function;
	showSizeChanger: boolean;
	pageSizeOptions: string[];
	showSizeChange: Function;
	size: string;
	showQuickJumper: boolean;
	defaultPageSize: number;
}

export let pagination = ref<any>({
	// 数据总数
	total: 0,
	// 当前页数
	current: 1,
	// 每页条数
	pageSize: 10,
	// 展示总数
	showTotal: (total: number) => `共 ${total} 条`,
	// 是否可以改变pageSize
	showSizeChanger: true,
	// 设置每页可以展示多少条的选项
	pageSizeOptions: ['10', '20', '50', '100'],
	// 改变pageSize后触发
	showSizeChange: (current: number, pageSize: any) => (
		(pagination.value.current = current),
		(pagination.value.pageSize = pageSize)
	),
	// 小尺寸分页
	size: 'small',
	// 是否可以快速跳转至某页
	showQuickJumper: true,
	//默认条数
	defaultPageSize: 10,
});

export const columns = ref<any>([
	{
		title: '用户编码',
		dataIndex: 'code',
		width: '100px',
		key: 'code',
	},
	{
		title: '手机号码',
		dataIndex: 'phone',
		key: 'phone',
		width: '180px',
	},
	{
		title: '用户状态',
		dataIndex: 'status',
		key: 'status',
		width: '100px',
		align: 'center',
	},
	{
		title: '微信',
		dataIndex: 'wechatOpenid',
		key: 'wechatOpenid',
		align: 'center',
	},
	{
		title: '头像',
		dataIndex: 'avatar',
		key: 'avatar',
		align: 'center',
		width: '180px',
	},
	{
		title: '隐藏手机号',
		dataIndex: 'hiddenPhone',
		width: '120px',
		align: 'center',
		key: 'hiddenPhone',
	},
	{
		title: '仅自己可见',
		dataIndex: 'self',
		width: '120px',
		align: 'center',
		key: 'self',
	},
	{
		title: '来源',
		dataIndex: 'source',
		align: 'center',
		key: 'source',
	},
	{
		title: '真实姓名',
		dataIndex: 'idCardName',
		key: 'idCardName',
		align: 'center',
		width: '120px',
	},
	{
		title: '身份证',
		dataIndex: 'idCardNumber',
		key: 'idCardNumber',
		align: 'center',
		width: '120px',
	},
	{
		title: '单身标识',
		dataIndex: 'singleFlag',
		key: 'singleFlag',
		align: 'center',
		width: '90px',
	},
	{
		title: '会员',
		dataIndex: 'membershipFlag',
		key: 'membershipFlag',
		align: 'center',
		width: '90px',
	},
	{
		title: '会员类型',
		dataIndex: 'membershipName',
		key: 'membershipName',
		align: 'center',
		width: '120px',
	},
	{
		title: '会员有效期',
		dataIndex: 'membershipExpireTime',
		key: 'membershipExpireTime',
		width: '160px',
	},
	{
		title: '红娘',
		dataIndex: 'matchmakerFlag',
		key: 'matchmakerFlag',
		align: 'center',
		width: '90px',
	},
	{
		title: '红娘编码',
		dataIndex: 'matchmakerNo',
		key: 'matchmakerNo',
		width: '100px',
	},
	{
		title: '红娘职级',
		dataIndex: 'matchmakerPositionLevelName',
		key: 'matchmakerPositionLevelName',
		width: '120px',
	},
	{
		title: '合伙人',
		dataIndex: 'partnerFlag',
		key: 'partnerFlag',
		align: 'center',
		width: '90px',
	},
	{
		title: '合伙人类型',
		dataIndex: 'partnerTypeName',
		key: 'partnerTypeName',
		width: '120px',
	},
	{
		title: '合伙人有效期',
		dataIndex: 'partnerExpireTime',
		key: 'partnerExpireTime',
		width: '200px',
	},
	{
		title: '操作',
		key: 'operation',
		fixed: 'right',
		width: '160px',
	},
]);

export interface DataItem {
	username: string;
	password: string;
	phone: string;
	code: string;
	status: string;
	wechatOpenid: string;
	wechatUnionid: string;
	avatar: number;
	self: number;
	wechatBindTime?: Dayjs | string;
	introUserId: number;
	codeNum: number;
	source: number;
	membershipFlag?: boolean;
	membershipName?: string;
	matchmakerFlag?: boolean;
	partnerFlag?: boolean;
	membershipExpireTime?: string;
	matchmakerNo?: number;
	matchmakerPositionLevelName?: string;
	partnerTypeName?: string;
	partnerStartTime?: string;
	partnerEndTime?: string;
	partnerExpireTime?: string;
}

export interface ModelInfo {
	title?: string;
	width?: string;
	id?: number | undefined;
	confirmLoading?: boolean;
}

export interface dictInfo {
	typeCode?: string | number | undefined;
	typeName?: string | undefined;
}

export const getSourceName = (source: number) => {
	switch (source) {
		case 1:
			return '官方来源';
		case 2:
			return '红娘';
		case 3:
			return '婚介所';
		default:
			return '未知';
	}
};